//
// Created by hjie on 23-9-3.
//

#include "user_inout_protocol.h"
#include "msg_key.h"
#include "base_protocol.h"

UserInProtocol::UserInProtocol()
{

}

void UserInProtocol::Dump(rapidjson::Document &output)
{
    BaseProtocol::Dump(output);

}

bool UserInProtocol::ParseData(rapidjson::Document &input)
{
    return true;
}


UserInResponseProtocol::UserInResponseProtocol()
{

}


void UserInResponseProtocol::Dump(rapidjson::Document &output)
{
    BaseProtocol::Dump(output);
    hnhj::AddObjectMember(output, content_k);
    hnhj::AddArrayMember(output[content_k], output.GetAllocator(), user_list_k);
    for (auto & user_id : m_user_set)
    {
        rapidjson::Value user_id_value(user_id.c_str(), user_id.size(), output.GetAllocator());
        output[content_k][user_list_k].PushBack(user_id_value, output.GetAllocator());
    }
}

UserInBroadcastResponseProtocol::UserInBroadcastResponseProtocol()
{

}

void UserInBroadcastResponseProtocol::Dump(rapidjson::Document &output)
{
    BaseProtocol::Dump(output);
    hnhj::AddObjectMember(output, content_k);
    hnhj::AddStringMember(output[content_k], output.GetAllocator(), user_id_k, m_user_id);
}

UserOutProtocol::UserOutProtocol()
{

}

bool UserOutProtocol::ParseData(rapidjson::Document &input)
{
    return true;
}

void UserOutResponseProtocol::Dump(rapidjson::Document &output)
{
    BaseProtocol::Dump(output);

    hnhj::AddObjectMember(output, content_k);

    rapidjson::Value & content = output[content_k];
    if (!m_left_user_id.empty())
    {
        hnhj::AddStringMember(content, output.GetAllocator(), user_id_k, m_left_user_id);
    }
}